1. /* sdmrwput.cpp by K.Tsuru */
  2. // function ID = 345 DRADIX , BRADIX
  3. /****************************
  4. SDouble and SDecimal classes
  5. output in raw representation
  6. ****************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. long SDouble::RawPut(int crlf) const{
  11. long cCount = 0;
  12. uint p = 0;
  13. int nc = 0; //the number of digits and delimters per line
  14. const int width = (Radix() == DRADIX) ? DFIGURES : BFIGURES;
  15. int nl = displayWidth/(width+1); //the number per line
  16. uint vsize = figure.size();
  17. FILE* out = FileStream();
  18. //output negative sign
  19. if(Sign(345) < 0){ putc('-', out); cCount++; }
  20. cCount += fprintf(out, "%" fTypeFormat".+\n", figure(p++));
  21. for( ; p < vsize; p++){
  22. cCount += fprintf(out, "%0*" fTypeFormat, width, figure(p));
  23. nc++;
  24. if(nc == nl){
  25. putc('\n', out); cCount++; nc = 0;
  26. } else if(p < vsize-1){
  27. putc(' ', out); cCount++;
  28. }
  29. }
  30. //It shows the radix, exponent and size.
  31. char buff[displayWidth+1];
  32. if(Type() == REAL){
  33. if(rdxExp >= 0) sprintf(buff," x %" fTypeFormat"^%d (size = %u)", DRADIX, rdxExp, vsize);
  34. else sprintf(buff," x %" fTypeFormat"^(%d) (size = %u)", DRADIX, rdxExp, vsize); //outputs when zero
  35. } else {
  36. sprintf(buff,"(radix = %" fTypeFormat", size = %u)", BRADIX, vsize);
  37. }
  38. if( displayWidth - nc*(width+1) < strlen(buff) ){
  39. putc('\n', out); cCount++;
  40. }
  41. cCount += fprintf(out, "%s", buff);
  42. if(crlf){ putc('\n', out); cCount++; }
  43. return cCount;
  44. }

sdmrwput.cpp : last modifiled at 2017/07/17 15:28:13(1,478 bytes)
created at 2017/10/07 10:21:15
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).